<template>
  <j-modal
    :title='title'
    :width='1400'
    :visible='visible'
    switchFullscreen
    @ok='handleOk'
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel='handleCancel'
    cancelText='关闭'>
    <div>
      <a-table
        ref='table'
        size='middle'
        :scroll='{x:true}'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        class='j-table-force-nowrap'
        @change='handleTableChange'>
        <template slot='taskDes' slot-scope='text'>
          <j-ellipsis :value='text' :length='10' />
        </template>
        <template slot='htmlSlot' slot-scope='text'>
          <div v-html='text'></div>
        </template>
        <template slot='imgSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无图片</span>
          <img v-else :src='getImgView(text)' height='25px' alt=''
               style='max-width:80px;font-size: 12px;font-style: italic;' />
        </template>
        <template slot='fileSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无文件</span>
          <a-button
            v-else
            :ghost='true'
            type='primary'
            icon='download'
            size='small'
            @click='downloadFile(text)'>
            下载
          </a-button>
        </template>
      </a-table>
    </div>
  </j-modal>
</template>


<script>

import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'
import { filterDictTextByCache } from '@comp/dict/JDictSelectUtil'
import { sorter } from '@/utils/sorter'

export default {
  name: 'BusBusinessOpportunityListModel',
  mixins: [JeecgListMixin],
  components: {},
  data() {
    return {
      title: '',
      width: 1000,
      visible: false,
      disableSubmit: true,
      disableMixinCreated: true,
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '商机编号',
          align: 'center',
          dataIndex: 'num'
        },
        {
          title: '商机名称',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '客户简称',
          align: 'center',
          dataIndex: 'shortName'
        },
        {
          title: '销售经理',
          align: 'center',
          dataIndex: 'saleLeader'
        },
        {
          title: '售前经理',
          align: 'center',
          dataIndex: 'preSaleLeader'
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '修改时间',
          align: 'center',
          dataIndex: 'updateTime'
        },
        {
          title: '产品类型',
          align: 'center',
          dataIndex: 'type',
          customRender: (t) => {
            return filterDictTextByCache('icm_bus_business_opportunity_type', t) || '--'
          }
        },
        {
          title: '预计签单时间',
          align: 'center',
          dataIndex: 'expectSignTime',
          customRender: function(text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          }
        },
        {
          title: '商机阶段',
          align: 'center',
          dataIndex: 'stageLabel'
        }
      ],
      url: {
        details: '/bussiness/busBusinessOpportunity/details'
      }
    }
  },
  methods: {
    handleOk() {
    },
    handleCancel() {
      this.close()
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    queryOpportunity(record) {
      let name = record.name
      let time = record.time
      getAction(this.url.details, { name, time }).then((res) => {
        if (res.success) {
          // this.dataSource = res.result
          this.dataSource = res.result.records || res.result
        } else {
          this.$message.warning('操作失败！')
        }
      })
      this.visible = true
    }
  }
}

</script>

<style scoped>

</style>